import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import qrcode from '@feidao/web/atom/browser/msg/qrcode';
import { send_msg, spaceid } from '../../atom-web/config';
import query2url from '@feidao/web/atom/browser/url/query2url';
import storage_get from '@feidao/web/atom/browser/storage/get';


export default async function a003(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// 生成二维码
	const user = await storage_get('user');
	// {"_id":"439b2f7a-cc13-4677-8855-b2b2b2ad8a40","usercode":"Cl000001","user_name":"张芳","name_spell":"","is_disabled":false,"create_time":1545803522114,"productid":"jewelry_mall","avatar_path":"21b71310-f24f-4c94-bfcc-7a9449995e77","avatar_name":"xianyu","avatar_type":"png","email":"545025626@qq.com","phone":"18336402528","last_login_time":0,"phone_verified":true,"email_verified":false,"is_admin":false,"code":1,"msg":"SuccessFul","sessionID":"34cf7da2-5679-4dc7-a99d-092533a0480f"}
	// 支付需要的参数
	const doccode = new Date().getTime() + '';
	const sessionid = user.sessionID;
	const url = await query2url({ doccode, sessionid, spaceid }, 'http://172.16.15.43:8889/wx-ali-pay');
	const res = await qrcode(send_msg, url, 400, 400) as { code: string; result: string; };
	const result = res.result;
	const img = fd.data.node.querySelector('[data-feidao-id="pay_qrcode"]') as HTMLImageElement;
	// 添加前缀
	img.src = 'data:image/png;base64,' + result;
}
